package GameObjects.Ships.HyperDrives;

import java.awt.event.ActionListener;

import GUI.BottomPanel;
import GameObjects.Instances.Instances;
import GameObjects.Physics.Position;
import GameObjects.Ships.ShipObject;
import Logic.GameTime;

public abstract class HyperDrive extends ShipObject 
{
	private GameTime coolDownTime;
	private double requiredEnergy;
	private double energy;
	private boolean startCharging;
	private Position jumpPosition;
	
	public HyperDrive(Instances instances, Position position, double health, int coolDownTime, double requiredEnegery) 
	{
		super(instances, position, health);
		this.coolDownTime = new GameTime(coolDownTime);
		this.requiredEnergy = requiredEnegery;
		this.energy = 0;
		this.startCharging = false;
	}
	
	@Override
	public void setPanel(ActionListener actionListener, BottomPanel panel) 
	{
				
	}
	
	public void startCharging()
	{
		this.startCharging = true;
	}
	
	public double stopCharging()
	{
		this.startCharging = false;
		double returnEnergy = this.energy;
		this.energy = 0;
		return returnEnergy;
	}
	
	public boolean isCharged()
	{
		return this.energy == this.requiredEnergy;
	}
	
	public double rechargeEnegry(double energy)
	{
		if(this.startCharging)
		{
			double extra = 0;
			this.energy += energy;
			if(this.energy > this.requiredEnergy)
			{
				extra = this.energy - this.requiredEnergy;
				this.energy = this.requiredEnergy;
			}
			return extra;
		}
		this.energy = 0;
		return energy;
	}
	
	@Override
	public boolean tick()
	{
		return false;	
	}
}
